package com.lx.wx.restful.utils;

public class SystemEnums {

	/**
	 * 系统类型枚举
	 */
	public enum Project {

		LVXIA_FRONT_WEB(1, "LVXIA_FRONT_WEB", "ARCHIST网站系统"), LVXIA_FRONT_WS(2, "LVXIA_FRONT_WS", "业务接口系统"), LVXIA_FRONT_COMMENT_WS(3, "LVXIA_FRONT_COMMENT_WS", "评论接口系统");

		private Integer value;
		private String code;
		private String name;

		private Project(Integer value, String code, String name) {
			this.value = value;
			this.code = code;
			this.name = name;
		}

		public Integer getValue() {
			return this.value;
		}

		public String getCode() {
			return this.code;
		}

		public String getName() {
			return this.name;
		}

		public static String getProjectCode(Integer value) {
			if (value != null) {
				for (Project project : Project.values()) {
					if (project.getValue() == value) {
						return project.getCode();
					}
				}
			}
			return Project.LVXIA_FRONT_WEB.code;
		}

		public static String getProjectName(Integer value) {
			if (value != null) {
				for (Project project : Project.values()) {
					if (project.getValue() == value) {
						return project.getName();
					}
				}
			}
			return Project.LVXIA_FRONT_WEB.name;
		}
	}

	/**
  * 验证码发送类型枚举
	 */
	public enum CaptchaType {

		MOBILE_REGISTER(1, "MOBILE_REGISTER", "手机注册"),
		EMAIL_REGISTER(2, "EMAIL_REGISTER", "邮箱注册"),
		FIND_PASSWORD_MOBILE(3, "FIND_PASSWORD_MOBILE", "通过手机找回密码"),
		FIND_PASSWORD_EMAIL(4, "FIND_PASSWORD_EMAIL", "通过邮箱找回密码"),
		FIND_MONEY_PASSWORD_MOBILE(5, "FIND_MONEY_PASSWORD_MOBILE", "通过手机找回资金密码"),
		FIND_MONEY_PASSWORD_EMAIL(6, "FIND_MONEY_PASSWORD_EMAIL", "通过邮箱找回资金密码"),
		MOBILE_STATE(7, "MOBILE_STATE", "手机认证"),
		EMAIL_STATE(8, "EMAIL_STATE", "邮箱认证");

		private Integer value;
		private String code;
		private String name;

		private CaptchaType(Integer value, String code, String name) {
			this.value = value;
			this.code = code;
			this.name = name;
		}

		public Integer getValue() {
			return this.value;
		}

		public String getCode() {
			return this.code;
		}

		public String getName() {
			return this.name;
		}

		public static String getCaptchaTypeCode(Integer value) {
			if (value != null) {
				for (CaptchaType captchaType : CaptchaType.values()) {
					if (captchaType.getValue() == value) {
						return captchaType.getCode();
					}
				}
			}
			return CaptchaType.MOBILE_REGISTER.code;
		}

		public static String getCaptchaTypeName(Integer value) {
			if (value != null) {
				for (CaptchaType captchaType : CaptchaType.values()) {
					if (captchaType.getValue() == value) {
						return captchaType.getName();
					}
				}
			}
			return CaptchaType.MOBILE_REGISTER.name;
		}
	}

	/**
	 * 错误码类型枚举
	 */
	public enum ErrorCode {

		NEED_LOGIN(000, "当前操作需要先登录"),
		PARAMETER_SET_IS_INVALID(300, "参数设置是无效的"),
		PARAMETER_VALUE_IS_INVALID(301, "参数值是无效的"),
		UNKNOW_EXCEPTION(400, "未知异常"),
		NOT_EXIST(404, "记录不存在"),
		CANNOT_EXECUTE_OPERATION(303, "不能执行此操作"),
		REPEAT_OPERATION(302, "重复操作"),
		HAS_EXIST(100, "记录已存在"),
		CAPTCHA_ERROR(102, "验证码错误"),
		GET_CAPTCHA_ERROR(103, "获取验证码错误"),
		UNKNOW_DEVICE(104, "不支持设备"),
		DO_FOLLOW_ERROR(1001, "关注用户操作失败"),
		DO_UNFOLLOW_ERROR(1002, "取消关注用户操作失败"),
		PASSWORD_ERROR(1003, "验证用户登录帐号或密码操作错误，请重新输入！"),
		MOBILE_STATE_ERROR(1004, "用户手机未通过认证"),
		EMAIL_STATE_ERROR(1005, "用邮箱未通过认证"),
		REPEAT_TOP_ERROR(1006, "暂无权限置顶操作"),
		FOLLOW_NOT_EXIST(1007, "关注关系不存在"),
		MONEY_PASSWORD_ERROR(1008, "验证用户资金密码操作失败"),
		CERTIFIED_USERNAME_ERROR(1009, "用户实名认证操作失败"),
		MOBILE_ERROR(1010, "用户手机号码无效"),
		EMAIL_ERROR(1011, "用户电子邮箱无效"),
		SAME_PASSWORD_ERROR(1012, "新密码不能和老密码相同"),
		REPEAT_PRAISE_ERROR(1013, "你已经赞过，不能再赞了"),
		USER_NOT_EXIST(1014, "帐号不存在");

		private int code;
		private String msg;

		private ErrorCode(int code, String msg) {
			this.code = code;
			this.msg = msg;
		}

		public int getCode() {
			return this.code;
		}

		public String getMsg() {
			return this.msg;
		}

		public static String getErrorMsg(Integer code) {
			if (code != null) {
				for (ErrorCode errorCode : ErrorCode.values()) {
					if (errorCode.getCode() == code) {
						return errorCode.getMsg();
					}
				}
			}
			return ErrorCode.UNKNOW_EXCEPTION.msg;
		}
	}
}
